﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ZhuanGuanJHSR.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.JiHuaGL.ZhuanGuanJH.ZhuanGuanJHSR"  Theme="Default"%>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

 <!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../../../../../JS/jquery.js"></script>   
    <script src="../../../../../JS/AddEditCancel.js"></script>
    
    <script type="text/javascript">
        function display(op, id) {
            hdCollection.Set("ID", id);
           if (op == "edit") {
                lblOperateTip.SetText("修改");
                txtBianHao.SetEnabled(false);
                txtMingCheng.SetEnabled(false);
                txtJiHuaL.SetEnabled(true);
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                ASPxCallback1.PerformCallback("setinfo");
                txtJiHuaL.Focus();
            }
            else {
                $("#GridViewContentTable").hide();
                listCover(false, "divList");
            }
        }

        function save() {
            if (txtJiHuaL.GetText() == "") {
                alert("计划量必须输入！");
                txtJiHuaL.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("save");
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "setinfo") {
                txtBianHao.SetText(arr[2]);
                txtMingCheng.SetText(arr[3]);
                txtJiHuaL.SetText(arr[4]);
            }
            else if (type == "save") {
                if (arr[2] == "true") {
                    alert("保存成功！");
                    $("#GridViewContentTable").hide();
                    listCover(false, "divList");
                    gvList.PerformCallback();
                }
                else {
                    alert("保存失败！");
                }
            }
            
        }
       
        function begincall() {
            loadpanel1.Show();
        }
        function endcall() {
            loadpanel1.Hide();
            //定位添加或修改的记录
            var oid = hdCollection.Get("OperateID");
            var index = -1;
            if (oid != -1 && typeof (oid) != undefined) {
                for (var i = 0; i < gvList.GetVisibleRowsOnPage() ; i++) {
                    if (gvList.GetRowKey(i) == oid) {
                        index = i;
                    }
                }
                if (index != -1) {
                    gvList.SetFocusedRowIndex(index);
                    gvList.MakeRowVisible(index);
                    hdCollection.Set("OperateID", -1);
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
           专灌计划输入
        </div>
        <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
        <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中"></dx:ASPxLoadingPanel>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div>
                    <table style="width: 80%; margin: auto; float: left;">
                        <tr>
                            <td align="left" style="width: 8%">年份：
                            </td>
                            <td align="left" style="width: 18%">
                                <dx:ASPxComboBox ID="cmbNianF1" runat="server" Width="60%" OnSelectedIndexChanged="cmbNianF1_SelectedIndexChanged" AutoPostBack="true">
                                </dx:ASPxComboBox>
                            </td>
                            <td>
                                <dx:ASPxLabel ID="lbHeJi" ClientInstanceName="txtKaiCai" runat="server" >
                                </dx:ASPxLabel>
                            </td>
                              <td>
                                <dx:ASPxLabel runat="server" ID="lbcount" ForeColor="Blue"></dx:ASPxLabel>
                            </td> 
                        </tr>
                    </table>
                    <div id="divList">
                        <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" OnCustomCallback="gvList_CustomCallback">
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="I_Y" Caption="年份" Width="20%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_BUMENBH" Caption="主管部门编号" Width="30%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="I_ZHUANGUANJH" Caption="专灌计划（立方米）" Width="15%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="20px">
                                    <DataItemTemplate>
                                        <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                                <%--<dx:GridViewDataTextColumn Width="35px">
                                    <DataItemTemplate>
                                        <a href="#" onclick="del('<%#Eval("ID")%>')">删除</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>--%>
                            </Columns>
                            <ClientSideEvents Init="function(s,e){AdjustSize(450,gvList);}" BeginCallback="function(s,e){begincall();}" EndCallback="function(s,e){endcall();}" />
                        </dx:ASPxGridView>
                    </div>
                    <div style="text-align: right">
                      
                    </div>
                    <div style="height: 3px;"></div>
                    <div id="GridViewContentTable" style="display: none">
                        <div class="tabletitle1" align="center">
                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="添加"></dx:ASPxLabel>
                        </div>
                        <table style="width: 100%;">
                            <tr style="height: 40px">
                                <td style="width: 15%; text-align: right">部门编号：</td>
                                <td style="width: 20%" align="left" >
                                    <dx:ASPxTextBox ID="txtBianHao" ClientInstanceName="txtBianHao" runat="server" MaxLength="5">
                                        <%--<ClientSideEvents KeyUp="function(s,e){inputNum(s);OnKeyNext(txtMingCheng);}" />--%>
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">部门名称：</td>
                                <td align="left">
                                    <dx:ASPxTextBox ID="txtMingCheng" ClientInstanceName="txtMingCheng" runat="server" MaxLength="15">
                                        <%--<ClientSideEvents KeyPress="function(s,e){OnKeyNext(memoMiaoShu);}" />--%>
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>

                                <td style="text-align: right">按：</td>
                                <td style="float: left;">
                                    <dx:ASPxComboBox ID="cmbShuRu" runat="server" Width="50%" AutoPostBack="false">
                                        <Items>
                                            <dx:ListEditItem Text="万立方米" Value="1" Selected="true" />
                                            <dx:ListEditItem Text="立方米" Value="2" />
                                        </Items>
                                    </dx:ASPxComboBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right">计划量：</td>
                                <td align="left">
                                    <table>
                                        <tr>
                                            <td>
                                                <dx:ASPxTextBox ID="txtJiHuaL" ClientInstanceName="txtJiHuaL" runat="server">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                             
                        </table>
                        <table style="width: 100%">
                            <tr>
                                <td style="text-align: right;">
                                    <hr />
                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){save();}">
                                    </dx:ASPxButton>
                                    <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('init',-1);}" UseSubmitBehavior="false">
                                    </dx:ASPxButton>
                                </td>
                            </tr>
                        </table>
                    </div>

                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
